package com.danicsoft.daide.token;

/**
 * Thrown when an invalid token is encountered while parsing a byte stream.
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public class InvalidTokenException extends Exception {

	/**
	 * The token that could not be parsed.
	 */
	private Token offendingToken;

	/**
	 * Create a new InvalidTokenException based on the given token.
	 * 
	 * @param offendingToken
	 *        The token that cannot be parsed.
	 */
	public InvalidTokenException(Token offendingToken) {
		super("Invalid token discovered: " + offendingToken.toString());
		this.offendingToken = offendingToken;
	}

	/**
	 * Gets the token that could not be parsed and caused this exception
	 * 
	 * @return The offending token.
	 */
	public Token getOffendingToken() {
		return offendingToken;
	}

}
